package com.hjc.demo.quartz;

import org.quartz.Job;
import org.quartz.JobExecutionContext;
import org.quartz.JobExecutionException;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.function.Supplier;

public class HelloJob1 implements Job {
    private static final SimpleDateFormat sdf =new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");

    private Supplier<String> supplier;


    @Override
    public void execute(JobExecutionContext context) throws JobExecutionException {
        Date now = new Date();
        String currentTime = sdf.format(now);
        System.out.println("执行时间为：" + supplier + currentTime);
    }

    public void setData(Supplier<String> supplier) {
        this.supplier = supplier;
    }

}
